import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
  state: { userInfo: null, subjectInfo: null },
  mutations: {
    SET_USERINFO: (state, userInfo) => {
      state.userInfo = userInfo;
    },
    SET_SUBJECTINFO: (state, subjectInfo) => {
      state.subjectInfo = subjectInfo;
    }
  },
  actions: {
    setUserInfo({ commit }, data) {
      commit('SET_USERINFO', data);
    },
    setSubjectInfo({ commit }, data) {
      commit('SET_SUBJECTINFO', data);
    }
  },
  getters: {
    // 用户信息
    userInfo: (state) => {
      return state.userInfo;
    },
    subjectInfo: (state) => {
      return state.subjectInfo;
    }
  },
  modules: {}
});
